<?php
echo $this->translate('number').','. $this->translate('student id').','.$this->translate('student name').',';
foreach($this->semestetSubjectArr as $val)
foreach($val as $row)
echo $row['name'].',';
echo $this->translate('total average').','.$this->translate('judgement')."\n";

foreach($this->scoreData as $row) {
    $arr = array();
    $totalScore = $totalAvgCount = 0;
    foreach($row['Student_Model_StudentScoreSemester'] as $val)
    $arr[$val['subject_sn']] = $val['score'];

    echo $row['number'].','.$row['student_id'].','.$row['name'].',';

    foreach ($this->semestetSubjectArr as $subArr) {
        $sum = $avgCount = 0;
        foreach ($subArr as $subjectData) {
            if(isset($arr[$subjectData['subject_sn']]))  {
                $sum += $arr[$subjectData['subject_sn']] * $this->subjectRate[$subjectData['subject_sn']];
                $avgCount += $this->subjectRate[$subjectData['subject_sn']];
                echo $arr[$subjectData['subject_sn']].',';
                $totalScore += $sum;
                $totalAvgCount += $avgCount;
            }
            else echo '-,';
        }
//        if (count($subArr) >1)  {
//            if ($avgCount>0)
//            echo round($sum/$avgCount,2);
//        }

    }
    if ($totalAvgCount > 0) {
        $totalAverage = $totalScore/$totalAvgCount;
        echo round($totalAverage,2);
    }
    echo ',';
    if (isset($totalAverage))
    echo Semester_Model_SemesterExamine::resolveJudgement($totalAverage, $this->judgement);
    echo "\n";
}



